<?php

namespace addons\prl;

use app\common\library\Menu;
use think\Addons;

/**
 * 插件
 */
class Prl extends Addons
{

    /**
     * 插件安装方法
     * @return bool
     */
    public function install()
    {
        $menu = [
        	[
        		'name'	=> 'prl',
        		'title'   => '内容管理系统',
                'icon'    => 'fa fa-list',
        		'sublist' => [
        			[
				        "name" => "prl/articles",
				        "title" => "文章管理",
				        "icon" => "fa fa-file-text-o",
				        "ismenu" => 1,
				        "sublist" => [
				            [
				                "name" => "prl/articles/index",
				                "title" => "查看"
				            ],
				            [
				                "name" => "prl/articles/recyclebin",
				                "title" => "回收站"
				            ],
				            [
				                "name" => "prl/articles/add",
				                "title" => "添加"
				            ],
				            [
				                "name" => "prl/articles/edit",
				                "title" => "编辑"
				            ],
				            [
				                "name" => "prl/articles/del",
				                "title" => "删除"
				            ],
				            [
				                "name" => "prl/articles/destroy",
				                "title" => "真实删除"
				            ],
				            [
				                "name" => "prl/articles/restore",
				                "title" => "还原"
				            ],
				            [
				                "name" => "prl/articles/multi",
				                "title" => "批量更新"
				            ]
				        ]
				    ],
				    [
				        "name" => "prl/channels",
				        "title" => "栏目管理",
				        "icon" => "fa fa-columns",
				        "ismenu" => 1,
				        "sublist" => [
				            [
				                "name" => "prl/channels/index",
				                "title" => "查看"
				            ],
				            [
				                "name" => "prl/channels/add",
				                "title" => "添加"
				            ],
				            [
				                "name" => "prl/channels/edit",
				                "title" => "编辑"
				            ],
				            [
				                "name" => "prl/channels/del",
				                "title" => "删除"
				            ],
				            [
				                "name" => "prl/channels/multi",
				                "title" => "批量更新"
				            ],
				            [	
				            	'name' => 'prl/channels/viewsconfig', 
				            	'title' => '栏目配置'
				            ],
				        ]
				    ],
				    [
				        "name" => "prl/slides",
				        "title" => "广告管理",
				        "icon" => "fa fa-sliders",
				        "ismenu" => 1,
				        "sublist" => [
				            [
				                "name" => "prl/slides/index",
				                "title" => "查看"
				            ],
				            [
				                "name" => "prl/slides/add",
				                "title" => "添加"
				            ],
				            [
				                "name" => "prl/slides/edit",
				                "title" => "编辑"
				            ],
				            [
				                "name" => "prl/slides/del",
				                "title" => "删除"
				            ],
				            [
				                "name" => "prl/slides/multi",
				                "title" => "批量更新"
				            ]
				        ]
				    ],
				    [
				        "name" => "prl/models",
				        "title" => "模型管理",
				        "icon" => "fa fa-circle-o\r",
				        "ismenu" => 1,
				        "sublist" => [
				            [
				                "name" => "prl/models/index",
				                "title" => "查看"
				            ],
				            [
				                "name" => "prl/models/add",
				                "title" => "添加"
				            ],
				            [
				                "name" => "prl/models/edit",
				                "title" => "编辑"
				            ],
				            [
				                "name" => "prl/models/del",
				                "title" => "删除"
				            ],
				            [
				                "name" => "prl/models/multi",
				                "title" => "批量更新"
				            ]
				        ]
				    ],
				    [
				        "name" => "prl/views",
				        "title" => "视图管理",
				        "icon" => "fa fa-circle-o\r",
				        "ismenu" => 1,
				        "sublist" => [
				            [
				                "name" => "prl/views/index",
				                "title" => "查看"
				            ],
				            [
				                "name" => "prl/views/add",
				                "title" => "添加"
				            ],
				            [
				                "name" => "prl/views/edit",
				                "title" => "编辑"
				            ],
				            [
				                "name" => "prl/views/del",
				                "title" => "删除"
				            ],
				            [
				                "name" => "prl/views/multi",
				                "title" => "批量更新"
				            ]
				        ]
				    ],
				    [
				        "name" => "prl/forms",
				        "title" => "表单管理",
				        "icon" => "fa fa-circle-o\r",
				        "ismenu" => 1,
				        "sublist" => [
				            [
				                "name" => "prl/forms/index",
				                "title" => "查看"
				            ],
				            [
				                "name" => "prl/forms/add",
				                "title" => "添加"
				            ],
				            [
				                "name" => "prl/forms/edit",
				                "title" => "编辑"
				            ],
				            [
				                "name" => "prl/forms/del",
				                "title" => "删除"
				            ],
				            [
				                "name" => "prl/forms/multi",
				                "title" => "批量更新"
				            ]
				        ]
				    ],
				    [
				        "name" => "prl/viewsfields",
				        "title" => "视图字段管理",
				        "icon" => "fa fa-circle-o\r",
				        "ismenu" => 1,
				        "sublist" => [
				            [
				                "name" => "prl/viewsfields/index",
				                "title" => "查看"
				            ],
				            [
				                "name" => "prl/viewsfields/add",
				                "title" => "Add"
				            ],
				            [
				                "name" => "prl/viewsfields/edit",
				                "title" => "Edit"
				            ],
				            [
				                "name" => "prl/viewsfields/del",
				                "title" => "删除"
				            ],
				            [
				                "name" => "prl/viewsfields/multi",
				                "title" => "批量更新"
				            ]
				        ]
				    ]
        		]
        	]
		];
		Menu::create($menu);
        return true;
    }

    /**
     * 插件卸载方法
     * @return bool
     */
    public function uninstall()
    {
        Menu::delete("prl");
        return true;
    }

    /**
     * 插件启用方法
     * @return bool
     */
    public function enable()
    {
        Menu::enable("prl");
        return true;
    }

    /**
     * 插件禁用方法
     * @return bool
     */
    public function disable()
    {
        Menu::disable("prl");
        return true;
    }

    /**
     * 实现钩子方法
     * @return mixed
     */
    public function testhook($param)
    {
        // 调用钩子时候的参数信息
        print_r($param);
        // 当前插件的配置信息，配置信息存在当前目录的config.php文件中，见下方
        print_r($this->getConfig());
        // 可以返回模板，模板文件默认读取的为插件目录中的文件。模板名不能为空！
        //return $this->fetch('view/info');
    }

}
